iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 30
0
自我挑戰組

30天菜鳥學 Linux 系列 第 30

30天-學會如何查 port 的占用狀況

  • 分享至 

  • xImage
  •  

今天進度 : How do I check if a port is in use on Linux? - nixCraft

學會如何查 port 的占用狀況

可以使用 /etc/services

root@test:~# cat /etc/services
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
#
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.

tcpmux		1/tcp				# TCP port service multiplexer
echo		7/tcp
echo		7/udp
discard		9/tcp		sink null
discard		9/udp		sink null
systat		11/tcp		users
daytime		13/tcp
daytime		13/udp
netstat		15/tcp
qotd		17/tcp		quote
chargen		19/tcp		ttytst source
chargen		19/udp		ttytst source
...

但是單純使用資訊太多了,可以使用 grep -w {port} 篩選指定的 port

root@test:~# grep -w 80 /etc/services
http		80/tcp		www		# WorldWideWeb HTTP

只想查詢 tcp 跟 udp egrep -w '53/(tcp|udp)' /etc/services

root@test:~# egrep -w '53' /etc/services
domain		53/tcp				# Domain Name Server
domain		53/udp

root@test:~# egrep -w '53/(tcp)' /etc/services
domain		53/tcp				# Domain Name Server


上一篇
29天-重新開始學習 docker
下一篇
31天-繼續學習 docker build
系列文
30天菜鳥學 Linux 59
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言